<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8" />
	<meta name="viewport" content="width=device-width, initial-scale=1.0">

	<title>角色管理</title>
	<!--ztree-->
	<link rel="stylesheet" href="__JS__/ztree/demo.css" type="text/css">
	<link rel="stylesheet" href="__JS__/ztree/metroStyle.css" type="text/css">

	<!-- bootstrap -->
	<link href="__CSS__/bootstrap/bootstrap.css" rel="stylesheet" />

	<!-- libraries -->
	<!-- <link href="css/libs/jquery-ui-1.10.2.custom.css" rel="stylesheet" type="text/css" /> -->
	<link href="__CSS__/libs/font-awesome.css" type="text/css" rel="stylesheet" />

	<!-- global styles -->
	<link rel="stylesheet" type="text/css" href="__CSS__/compiled/layout.css">
	<link rel="stylesheet" type="text/css" href="__CSS__/compiled/elements.css">

	<!-- this page specific styles -->
	<link rel="stylesheet" type="text/css" href="__CSS__/libs/bootstrap-wizard.css">
	<link rel="stylesheet" href="__CSS__/libs/select2.css" type="text/css" />

	<link rel="stylesheet" href="__CSS__/new.css"/>
	<link rel="stylesheet" href="__CSS__/table.css"/>
	<link rel="stylesheet" href="__CSS__/bootstrap-table.css"/>
	<link rel="stylesheet" href="__CSS__/bootstrap-table-fixed-columns.css"/>


	<!-- Favicon -->
	<!--<link type="image/x-icon" href="favicon.png" rel="shortcut icon"/>-->

	<!-- google font libraries -->
	<link href='http://fonts.googleapis.com/css?family=Open+Sans:400,600,700,300|Titillium+Web:200,300,400' rel='stylesheet' type='text/css'>

	<!--[if lt IE 9]>
	<!--<script src="__JS__/html5shiv.js"></script>
	<script src="__JS__/respond.min.js"></script>-->
	<![endif]-->
	<!--[if lt IE 8]>-->
		<!--<link href="__CSS__/libs/font-awesome-ie7.css" type="text/css" rel="stylesheet" />-->
	<script>
	  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
	  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
	  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
	  })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

	  ga('create', 'UA-49262924-1', 'phoonio.com');
	  ga('send', 'pageview');

	</script>
	<style>

		.fixed-table-body-columns{
			height: 486px!important;
			top: 47px!important;
		}
		/*弹出框*/
		.wizard-steps{
			display: none;
		}
		.wizard-card{
			width:400px!important;
			height: 400px!important;
		}
		.wizard-modal.modal{
			width:400px!important;
			height: 520px!important;
			margin-left: -200px!important;
		}
		.wizard-back{
			display: none!important;
		}
		.calCancel{
			float: right;
		}


	</style>
</head>
<body>
	<!--head-->
	{include file="pub/head"/}

	<div class="container" role="main">
		<div class="row">

			<!--left-->
			{include file="pub/left"/}
			<div class="col-md-10" id="content-wrapper">
				<!--<h2 class="pull-left">Last orders</h2>-->
				<div class="row">
					<div class="col-lg-12">

							<div class="col-lg-12">
								<div class="main-box">

									<!--提示框-->
									{include file="pub/tips"/}

									<div class="clear-fix">
										{if condition="in_array('Role/save',$ownways)"}
										<button id="open-wizard" class="btn btn-primary">
											<i class="fa fa-plus-circle fa-lg"></i> 添加角色
										</button>
										{/if}

										<div class="filter-block pull-right">
											<form action="{:url('Role/search')}" method="post">
												<div class="form-group pull-left">
													<input type="text" class="form-control" name="search" placeholder="Search...">
												</div>
												<button class="btn btn-primary pull-right">
													<i class="fa fa-search search-icon"></i> 搜索
												</button>
											</form>
										</div>

									</div>
									<br>
									<div class="table-responsive clearfix">
										<table id="fixedTable" class="table table-striped jambo_table table-hover" data-toggle="table">
											<thead>
												<tr>

													<th><span>角色编号</span></th>
													<th><span>角色名称</span></th>
													<th><span>备注</span></th>
													<th><span>添加日期</span></th>
													<!--<th><span>状态</span></th>-->
													<th><span>操作</span></th>
												</tr>
											</thead>
											<tbody>
												{volist name="roles" id="v"}
												<tr>
													<td>{$v.role_id}</td>
													<td>{$v.role_name}</td>
													<td>{$v.remark}</td>
													<td>{$v.create_time}</td>
													<!--<td>{$v.status}</td>-->
													<td>
														{if condition="in_array('Role/esave',$ownways)"}
														<a class="table-link" title="修改" onclick=edit("{$v['role_id']}","{$v['wid']}")>
															<span class="fa-stack">
																<i class="fa fa-square fa-stack-2x"></i>
																<i class="fa fa-pencil fa-stack-1x fa-inverse"></i>
															</span>
														</a>
														{/if}
														{if condition="in_array('Role/del',$ownways)"}
														<a class="table-link danger class-del class-del" onclick=del("{$v['role_id']}") title="删除">
															<span class="fa-stack">
																<i class="fa fa-square fa-stack-2x"></i>
																<i class="fa fa-trash-o fa-stack-1x fa-inverse"></i>
															</span>
														</a>
														{/if}
													</td>
												</tr>
												{/volist}

											</tbody>
										</table>
										<!--分页-->
										<div style="text-align: center;">
											{$page}
										</div>
									</div>

								</div>
							</div>
						</div>
			</div>
		</div>
	</div>
	<!--foot-->
	{include file="pub/foot"/}
	</div>
<!-- global scripts -->
</body>
<!--添加弹出框-->
{include file="role/add"/}
<!--修改弹出框-->
{include file="role/edit"/}
<!--删除弹出框-->
{include file="role/del"/}
<script src="__JS__/jquery.js"></script>

<script src="__JS__/bootstrap.min.js"></script>

<!-- this page specific scripts -->
<script src="__JS__/bootstrap-wizard.js"></script>
<script src="__JS__/select2.min.js"></script>

<!-- theme scripts -->
<script src="__JS__/scripts.js"></script>
<script src="__JS__/bootstrap-table.js"></script>
<script src="__JS__/bootstrap-table-fixed-columns.js"></script>
<!--ztree-->
<script type="text/javascript" src="__JS__/ztree/jquery.ztree.core.js"></script>
<script type="text/javascript" src="__JS__/ztree/jquery.ztree.excheck.js"></script>
<script type="text/javascript" src="__JS__/ztree/jquery.ztree.exedit.js"></script>

<script>
    /*$('#fixedTable').bootstrapTable('destroy').bootstrapTable({
        fixedColumns: true,//固定列
        fixedNumber:2 //固定前两列
    })*/
	$('#sel2').select2();

	$.fn.wizard.logging = false;

	var wizard = $("#wizard-demo").wizard({
		showCancel: true
	});
	var foredit = $("#wizard-edit").wizard({
		showCancel: true
	});

	wizard.el.find(".wizard-ns-select").change(function() {
		wizard.el.find(".wizard-ns-detail").show();
	});

	wizard.el.find(".create-server-service-list").change(function() {
		var noOption = $(this).find("option:selected").length == 0;
		wizard.getCard(this).toggleAlert(null, noOption);
	});

	wizard.cards["name"].on("validated", function(card) {
		var hostname = card.el.find("#new-server-fqdn").val();
	});

	wizard.on("submit", function(wizard) {

		setTimeout(function() {
			wizard.trigger("success");
			wizard.hideButtons();
			wizard._submitting = false;
			wizard.showSubmitCard("success");
			wizard.updateProgressBar(0);
		}, 1000);
		add();
		wizard.reset().close();
		setTimeout(function () {
			//刷新页面
			window.location.reload();
		},1000)

	});
	$(".wizard-group-list").click(function() {
		alert("Disabled for demo.");
	});

	$("#open-wizard").click(function() {
		wizard.show();
		$('.wizard-cancel').text('取消');
		$('.wizard-cancel').addClass('calCancel')
		// $('.wizard-next').addClass('calCancel')
		$('.wizard-next').text('确定');
	});


    /*提示信息不显示*/
    $("#msg").addClass('forhid')
    function add() {
        var treeObj = $.fn.zTree.getZTreeObj("treeAdd");
        var nodes = treeObj.getCheckedNodes();
        var tree = '';
        for(var i=0;i<nodes.length;i++){
            var treeNode = nodes[i]
            if(treeNode.checked == true){
                tree += treeNode.id + ',';
            }
            //console.log((treeNode?treeNode.name:"root") + "checked " +(treeNode.checked?"true":"false"));
        }
        //console.log(tree)
        $("input[name='wid_add']").val(tree)

        var role_name = $("input[name='role_name_add']").val();
        var remark = $("input[name='remark_add']").val();
        var wid = $("input[name='wid_add']").val();
        var status = $("select[name='status_add']").val();
        var data = {'role_name':role_name,'remark':remark,'wid':wid,'status':status};
        //console.log(data)
        $.ajax({
            //几个参数需要注意一下
            type: "POST",//方法类型
            dataType: "json",//预期服务器返回的数据类型
            url: "{:url('Role/save')}",//url
            data: data,
            success: function (result) {
                var code = result.code
                var msg = result.msg
                changeText(msg, code)

            },
            error:function (result) {
                var code = 0
                var msg = '服务器错误';
                changeText(msg, code)

            }
        });
    }
    function changeText(msg, code) {
        $('#sp').text(msg)
        if(code != 1){
            $('#img').attr('src', '__IMG__/fail.png')
        }
        $("#msg").removeClass('forhid')
        setTimeout("showOrHid()",2000)
    }
    function showOrHid() {
        //console.log('123')
        /*淡出效果*/
        $("#msg").fadeOut(2000)
        // $("#msg").addClass('forhid')
    }

    function del(role_id) {
        $.post("{:url('Role/one')}",{role_id:role_id},function(data){
            // console.log(data);
            if(data) {
                $("input[name='role_id']").val(data[0].role_id)
            }
        },'json');

    }

    $(function () {
        $(".alert-close").click(function () {
            $(".delete").css("display","none")
        })
        $(".alert-cancel").click(function () {
            $(".delete").css("display","none")
        })
        $(".class-del").click(function () {
            $(".delete").css("display","block")
        })

    })
</script>
</html>